package org.montecristo.posmobile.previo.camara;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.PixelFormat;
import android.view.SurfaceHolder;
import android.view.SurfaceView;

public class DrawView extends SurfaceView {
	private Paint textPaint = new Paint();	
	public boolean drawEnabled;

	public DrawView(Context context){
		super(context);
		// Create out paint to use for drawing
		textPaint.setARGB(220, 255, 255, 255);
		drawEnabled = false;

		this.setZOrderOnTop(true); // necessary
		SurfaceHolder sfhTrackHolder = this.getHolder();
		sfhTrackHolder.setFormat(PixelFormat.TRANSPARENT);

		textPaint.setStyle(Style.STROKE);
		textPaint.setStrokeWidth(2.0f);
		// This call is necessary, or else the
		// draw method will not be called.
		setWillNotDraw(false);
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		// A Simple Text Render to test the display
		
		//int offset = (canvas.getWidth() - canvas.getHeight()) / 2;
		// canvas.drawText(canvas.getWidth()+" "+canvas.getHeight(),canvas.getWidth()/2,
		// canvas.getHeight()/2, textPaint);
		// canvas.drawRect(offset,0,canvas.getWidth()-offset,canvas.getHeight(),
		// textPaint);
		if (drawEnabled)
			canvas.drawRect((canvas.getWidth() / 2) - (canvas.getWidth() / 5),
					(canvas.getHeight() / 2) - (canvas.getHeight() / 5),
					(canvas.getWidth() / 2) + (canvas.getWidth() / 5),
					(canvas.getHeight() / 2) + (canvas.getHeight() / 5),
					textPaint);
		// canvas.drawRect(0,0,offset,canvas.getHeight(),textPaint);
		// canvas.drawRect(canvas.getWidth()-offset,0,canvas.getWidth(),canvas.getHeight(),textPaint);
	}
}